home *** CD-ROM | disk | FTP | other *** search
- function onEnterFrame()
- {
- pauseManagement();
- if(gamePaused == false)
- {
- levelTimer += 0.04;
- levelTimerDisplay = Math.round(levelTimer);
- touchBuffer--;
- function_heroDeathManagement();
- function_HERO();
- function_CAMERA(camTarget,camElasticStore,camTypeStore,camXPos,camYPos);
- }
- }
- function pauseManagement()
- {
- if(Key.isDown(77) and pauseSwitch == false)
- {
- pauseSwitch = true;
- if(gamePaused == false)
- {
- gamePaused = true;
- }
- else
- {
- gamePaused = false;
- }
- }
- else if(Key.isDown(77) == false)
- {
- pauseSwitch = false;
- }
- }
- function function_HERO()
- {
- if(HERO.dead == false and HERO.win == false)
- {
- function_HERO_jump();
- function_gravity(this.HERO);
- function_HERO_hitRoof();
- function_HERO_hitGround();
- function_HERO_spriteGraphics();
- function_HERO_healthManagement();
- function_dangers();
- if(heroHitForeground() == true)
- {
- if(this.FOREGROUND._alpha > 50)
- {
- this.FOREGROUND._alpha -= 5;
- }
- }
- else if(this.FOREGROUND._alpha < 100)
- {
- this.FOREGROUND._alpha += 5;
- }
- function_HERO_hitWall(this.HERO.charWidth / 2,(- this.HERO.charHeight) / 2,1);
- function_HERO_hitWall((- this.HERO.charWidth) / 2,(- this.HERO.charHeight) / 2,-1);
- function_HERO_move();
- }
- else if(HERO.win == true)
- {
- function_gravity(this.HERO);
- function_heroWinManagement();
- function_HERO_hitGround();
- }
- }
- function function_HERO_move()
- {
- if(Key.isDown(39) and HERO.paralysisTimer == 0)
- {
- if(this.HERO.speed < this.HERO.maxSpeed)
- {
- this.HERO.speed += this.HERO.accel;
- }
- else
- {
- this.HERO.speed = this.HERO.maxSpeed;
- }
- }
- else if(Key.isDown(37) and HERO.paralysisTimer == 0)
- {
- if(this.HERO.speed > - this.HERO.maxSpeed)
- {
- this.HERO.speed -= this.HERO.accel;
- }
- else
- {
- this.HERO.speed = - this.HERO.maxSpeed;
- }
- }
- else
- {
- this.HERO.speed /= this.HERO.deccel;
- }
- if(Key.isDown(dashKey) == false)
- {
- this.HERO.speed /= this.HERO.dashSpeed;
- }
- this.HERO._x += this.HERO.speed;
- }
- function function_HERO_jump()
- {
- if(HERO.paralysisTimer == 0)
- {
- if(Key.isDown(jumpKey) and touchBuffer > 0 and this.HERO.jumpLock == false)
- {
- _parent.STAGE.newSound("Sound_Jump");
- this.HERO.jumpLock = true;
- this.HERO.drop = - this.HERO.jumpHeight;
- }
- if(HERO.drop >= (- HERO.jumpHeight) / 2 and Key.isDown(jumpKey) == false and doubleJumpCount < HERO.doubleJumps)
- {
- allowDoubleJump = true;
- }
- if(Key.isDown(jumpKey) and allowDoubleJump == true)
- {
- allowDoubleJump = false;
- doubleJumpCount++;
- this.HERO.drop = (- this.HERO.doubleJumpHeight) / doubleJumpDegrade;
- doubleJumpDegrade += HERO.doubleJumpDegrade;
- }
- if(Key.isDown(jumpKey) == false and touchBuffer > 0)
- {
- this.HERO.jumpLock = false;
- }
- }
- }
- function function_CAMERA(camTarg, camSpeed, camType, xPos, yPos)
- {
- if(Key.isDown(65) == false)
- {
- if(Key.isDown(camKeyUp))
- {
- camYOffset = 100;
- }
- else if(Key.isDown(camKeyDown))
- {
- camYOffset = -100;
- }
- else
- {
- camYOffset = 0;
- }
- if(Key.isDown(camKeyRight))
- {
- camXOffset = -100;
- }
- else if(Key.isDown(camKeyLeft))
- {
- camXOffset = 100;
- }
- else
- {
- camXOffset = 0;
- }
- if(camType == 1)
- {
- this._x += (xPos - camTarg._x - this._x + camXOffset) / camSpeed;
- this._y += (yPos - camTarg._y - this._y + camYOffset) / camSpeed;
- }
- else if(camType == 2)
- {
- this._x += (xPos - camTarg._x - this._x + camXOffset) / camSpeed;
- }
- else if(camType == 3)
- {
- this._y += (yPos - camTarg._y - this._y + camYOffset) / camSpeed;
- }
- }
- }
- function heroHitGround()
- {
- if(this.GROUND.hitTest(this.HERO._x + this._x,this.HERO._y + this._y,true))
- {
- if(HERO.drop == WORLD_gravity and touchBuffer < -18)
- {
- _parent.STAGE.newSound("Sound_Thud");
- function_newParticle(HERO._x,1,"Particle_FallSmoke",1);
- function_newParticle(HERO._x,0,"Particle_FallSmoke",1);
- }
- HERO.drop = 0;
- touchBuffer = 6;
- doubleJumpCount = 0;
- doubleJumpDegrade = 1;
- return true;
- }
- }
- function heroHitForeground()
- {
- if(this.FOREGROUND.hitTest(this.HERO._x + this._x,this.HERO._y + this._y,true))
- {
- return true;
- }
- }
- function heroHitWall(wallXPos, wallYPos)
- {
- if(this.GROUND.hitTest(this.HERO._x + wallXPos + this._x,this.HERO._y + wallYPos + this._y,true))
- {
- return true;
- }
- }
- function function_HERO_hitWall(wallXPos, wallYPos, wallDir)
- {
- if(heroHitWall(wallXPos,wallYPos) == true)
- {
- while(heroHitWall(wallXPos,wallYPos) == true)
- {
- this.HERO._x -= wallDir;
- }
- this.HERO.speed = 0;
- }
- }
- function heroHitRoof()
- {
- if(this.GROUND.hitTest(this.HERO._x + this._x,this.HERO._y + this._y - this.HERO.charHeight,true))
- {
- return true;
- }
- }
- function function_HERO_hitRoof()
- {
- if(heroHitRoof() == true)
- {
- while(heroHitRoof() == true)
- {
- this.HERO._y = this.HERO._y + 1;
- }
- this.HERO.drop = 1;
- }
- }
- function function_HERO_hitGround()
- {
- if(heroHitGround() == true)
- {
- while(heroHitGround() == true)
- {
- this.HERO._y--;
- this.HERO.drop = 0;
- }
- this.HERO._y += 1;
- }
- }
- function function_gravity(characterClass)
- {
- characterClass._y += characterClass.drop;
- if(characterClass.drop < WORLD_gravity)
- {
- characterClass.drop += WORLD_airResistance;
- }
- else
- {
- characterClass.drop = WORLD_gravity;
- }
- }
- function processInputKeys()
- {
- var _loc2_ = new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
- var _loc3_ = new Array(65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90);
- var _loc1_ = 0;
- while(_loc1_ < 26)
- {
- if(jumpKey == _loc2_[_loc1_])
- {
- jumpKey = _loc3_[_loc1_];
- }
- _loc1_ = _loc1_ + 1;
- }
- _loc1_ = 0;
- while(_loc1_ < 26)
- {
- if(attackKey == _loc2_[_loc1_])
- {
- attackKey = _loc3_[_loc1_];
- }
- _loc1_ = _loc1_ + 1;
- }
- _loc1_ = 0;
- while(_loc1_ < 26)
- {
- if(dashKey == _loc2_[_loc1_])
- {
- dashKey = _loc3_[_loc1_];
- }
- _loc1_ = _loc1_ + 1;
- }
- if(dashKey == null)
- {
- HERO.dashSpeed = 1;
- }
- }
- function function_HERO_spriteGraphics()
- {
- if(HERO.paralysisTimer > 0)
- {
- HERO.sprite.gotoAndStop("HURT");
- HERO.paralysisTimer--;
- }
- else if(touchBuffer < 3)
- {
- HERO.sprite.gotoAndStop("JUMP");
- }
- else if(Key.isDown(39))
- {
- if(Key.isDown(dashKey) or dashKey == null)
- {
- HERO.sprite.gotoAndStop("RUN");
- }
- else
- {
- HERO.sprite.gotoAndStop("WALK");
- }
- HERO.sprite._xscale = HERO.spriteScale;
- }
- else if(Key.isDown(37))
- {
- if(Key.isDown(dashKey) or dashKey == null)
- {
- HERO.sprite.gotoAndStop("RUN");
- }
- else
- {
- HERO.sprite.gotoAndStop("WALK");
- }
- HERO.sprite._xscale = - HERO.spriteScale;
- }
- else
- {
- HERO.sprite.gotoAndStop("STAND");
- }
- }
- function defaultCamera()
- {
- camTarget = camTarget_default;
- camTypeStore = camTypeStore_default;
- camElasticStore = camElasticStore_default;
- camXPos = camXPos_default;
- camYPos = camYPos_default;
- }
- function function_dangers()
- {
- if(this.DANGERS.hitTest(this.HERO._x + this._x,this.HERO._y + this._y,true))
- {
- function_HERO_hurt();
- }
- }
- function function_HERO_hurt()
- {
- if(HERO.invTimer == 0)
- {
- _parent.STAGE.newSound("Sound_Hurt");
- if(HERO.sprite._xscale > 0)
- {
- HERO.speed = -10;
- }
- else
- {
- HERO.speed = 10;
- }
- HERO.drop = -20;
- HERO.paralysisTimer = HERO.paralysisTime;
- HERO.invTimer = HERO.invTime;
- HERO.health--;
- }
- }
- function function_HERO_healthManagement()
- {
- if(HERO.invTimer > 0)
- {
- HERO.invTimer--;
- if(HERO.paralysisTimer == 0)
- {
- HERO.sprite._alpha = - HERO.sprite._alpha;
- }
- else
- {
- HERO.sprite._alpha = 100;
- }
- }
- else
- {
- HERO.sprite._alpha = 100;
- }
- }
- function function_newParticle(xPos, yPos, MC, number)
- {
- var _loc2_ = 0;
- while(_loc2_ < number)
- {
- var _loc1_ = EFFECTS.attachMovie(MC,"P" + effectCount,effectCount++);
- _loc1_._x = xPos;
- _loc1_._y = yPos;
- _loc2_ = _loc2_ + 1;
- }
- }
- function enemy(classID)
- {
- if(ENEMIES[classID].hitTest(_parent.STAGE))
- {
- if(ENEMIES[classID].hitTest(HERO.feet) and HERO.drop > 5)
- {
- if(Key.isDown(jumpKey))
- {
- HERO.drop = (- HERO.drop) * 1.5;
- }
- else
- {
- HERO.drop = - HERO.drop;
- }
- function_newParticle(ENEMIES[classID]._x,ENEMIES[classID]._y,"Class_Particle_Enemy",50);
- ENEMIES[classID].swapDepths(0);
- ENEMIES[classID].removeMovieClip();
- }
- else if(ENEMIES[classID].hitTest(HERO.body))
- {
- function_HERO_hurt();
- }
- }
- ENEMIES[classID]._y += ENEMIES[classID].drop;
- if(ENEMIES[classID].drop < WORLD_gravity)
- {
- ENEMIES[classID].drop += WORLD_airResistance;
- }
- if(enemy_groundHit(0,0,classID) == true)
- {
- while(enemy_groundHit(0,0,classID) == true)
- {
- ENEMIES[classID]._y--;
- }
- ENEMIES[classID]._y = ENEMIES[classID]._y + 1;
- ENEMIES[classID].drop = 0;
- }
- if(enemy_groundHit(40,-20,classID) == true or enemy_enemyHit(40,-20,classID) == true)
- {
- ENEMIES[classID].moveDir = -1;
- }
- else if(enemy_groundHit(-40,-20,classID) == true or enemy_enemyHit(-40,-20,classID) == true)
- {
- ENEMIES[classID].moveDir = 1;
- }
- enemy_speedControl(classID);
- }
- function enemy_groundHit(xPos, yPos, classID)
- {
- if(GROUND.hitTest(ENEMIES[classID]._x + _X + xPos,ENEMIES[classID]._y + _Y + yPos,true))
- {
- return true;
- }
- if(ENEMIES.hitTest(ENEMIES[classID]._x + _X + xPos,ENEMIES[classID]._y + _Y + yPos + 5,true))
- {
- return true;
- }
- }
- function enemy_enemyHit(xPos, yPos, classID)
- {
- if(ENEMIES.hitTest(ENEMIES[classID]._x + _X + xPos,ENEMIES[classID]._y + _Y + yPos,true))
- {
- return true;
- }
- }
- function enemy_speedControl(classID)
- {
- if(ENEMIES[classID].moveDir == 1)
- {
- if(ENEMIES[classID].speed < 5)
- {
- ENEMIES[classID].speed = ENEMIES[classID].speed + 1;
- }
- }
- else if(ENEMIES[classID].speed > -5)
- {
- ENEMIES[classID].speed--;
- }
- ENEMIES[classID]._x += ENEMIES[classID].speed;
- }
- function function_heroDeathManagement()
- {
- if(HERO.health == 0)
- {
- if(deathDelay > 0)
- {
- deathDelay--;
- }
- else
- {
- deathDelay = 10;
- HERO.dead = true;
- HERO._visible = false;
- _parent.STAGE.newSound("Sound_Glass");
- function_newParticle(HERO._x,HERO._y,"Class_Particle_Dead",100);
- function_newParticle(HERO._x,HERO._y - 20,"Class_Particle",50);
- HERO.health = 1;
- HERO.drop = -10;
- }
- }
- if(HERO.dead == true)
- {
- if(HERO.deadTimer < 30)
- {
- HERO.deadTimer = HERO.deadTimer + 1;
- if(HERO.deadTimer == 30)
- {
- _parent.STAGE.newSound("Sound_Swoosh");
- }
- }
- else if(HERO.deadTimer < 60)
- {
- HERO._x += (heroStartX - HERO._x) / 10;
- HERO._y = (heroStartY - HERO._y) / 10;
- HERO.deadTimer = HERO.deadTimer + 1;
- }
- else
- {
- HERO._x = heroStartX + 30;
- HERO._y = heroStartY - 10;
- function_newParticle(HERO._x,HERO._y - 20,"Class_Particle",50);
- _parent.STAGE.newSound("Sound_Glass");
- HERO.dead = false;
- HERO._visible = true;
- HERO.deadTimer = 0;
- HERO.invTimer = 0;
- }
- }
- }
- function function_heroWinManagement()
- {
- if(heroHitGround() == true)
- {
- while(heroHitGround() == true)
- {
- HERO._y--;
- }
- HERO.drop = -15;
- HERO.sprite._xscale = - HERO.sprite._xscale;
- }
- HERO.sprite.gotoAndStop("JUMP");
- }
- var jumpKey = 32;
- var attackKey = "D";
- var dashKey = null;
- var camKeyLeft = null;
- var camKeyRight = null;
- var camKeyUp = null;
- var camKeyDown = null;
- this.HERO.maxSpeed = 10;
- this.HERO.accel = 1;
- this.HERO.deccel = 1.2;
- this.HERO.jumpHeight = 25;
- this.HERO.doubleJumps = 0;
- this.HERO.doubleJumpHeight = 0;
- this.HERO.doubleJumpDegrade = 0;
- this.HERO.charWidth = 30;
- this.HERO.charHeight = 40;
- this.HERO.dashSpeed = 1.2;
- this.HERO.paralysisTime = 30;
- this.HERO.invTime = 120;
- this.HERO.deadTimerStore = 60;
- this.HERO.health = 1;
- var camTarget_default = this.HERO;
- var camTypeStore_default = 1;
- var camElasticStore_default = 5;
- var camXPos_default = 400;
- var camYPos_default = 300;
- var WORLD_gravity = 20;
- var WORLD_airResistance = 2;
- LEVEL = _parent.levelArray[_parent.levelID];
- HERO.deadTimer = 0;
- var heroStartX = HERO._x;
- var heroStartY = HERO._y;
- HERO.dead = false;
- defaultCamera();
- processInputKeys();
- HERO.spriteScale = HERO.sprite._xscale;
- var doubleJumpCount = 0;
- var doubleJumpDegrade = 0;
- var allowDoubleJump = false;
- createEmptyMovieClip("EFFECTS",1);
- _quality = "medium";
- deathDelay = 10;
- levelTimer = 0;
- levelTimerDisplay = levelTimer;
- itemCollect = 0;
- gamePaused = false;
- this.HERO.drop = 0;
- this.HERO.speed = 0;
- this.HERO.jumpSwitch = false;
- this.HERO.jumpLock = false;
- this.HERO.invTimer = 0;
- this.HERO.paralysisTimer = 0;
- HERO.win = false;
- effectCount = 0;
- enemyID = 0;
-